// void, Obj This, point pt
Hero this;
Unit u;
point dpt, dpt2;
bool toClose;
int i, dist;

Sleep(15);
this = This.AsHero();
if(!.IsValid) return;

toClose = false;
if(pt.Dist(.posRH) < 950){ 
    toClose = true;
    if(pt.Dist(.posRH) < 500){  
        dist = 300;
    }
}

.FormSetupAndMoveTo (pt, 0, 0, true); 

while (.HasPath()){
	CreateFeedback("StaminaLoss", this);
	.army.ClearDead;
	for (i=0; i<.army.count; i+=1){
		u = .army[i].AsUnit; 
		if(u.IsValid){
			if(u.IsAlive){
				Sleep(5);
				CreateFeedback("StaminaLoss", u);
				if(u.stamina > 0) u.SetStamina(0);
			}
		}
	}
	if(.army.count >= 20){
		if (.race==Carthage || .race==Egypt)
			.PlaySound("data/Sound Entities/VOICERETREATARAB.XML");
		else if(.race==ImperialRome || .race==RepublicanRome)
			.PlaySound("data/Sound Entities/VOICERETREATROMAN.XML");
		else if(.race==Gaul || .race==Iberia || .race==Britain || .race==Germany)        
			.PlaySound("data/Sound Entities/VOICERETREATBARB.XML");
	}
	if(pt.Dist(.posRH) < 300){
		if(toClose){
			toClose = false; 
			dpt2 = GetVecByDir(.GetDir(), dist+950);
			.FormSetupAndMoveTo (.pos+dpt2, 0, 0, true);
		}
	}
	.FormKeepMoving (1500);
	continue;
}

dpt = .GetFinalPartyOrientation() - Point(1024, 1024);
if (dpt.x != 0 || dpt.y != 0)
		.Face(.pos + dpt);

if(.IsAlive)
if(.HasArmy)
if(.CmdCount == 1){
	Sleep(rand(100)+10);
	.AddCommand(false, "stand_position");
}

